package com.gitee.wsl.compose.chart.sample

import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.gitee.wsl.common.ui.ext.color.randomList
import com.gitee.wsl.compose.chart.Chart
import com.gitee.wsl.compose.chart.gant.Gantt
import com.gitee.wsl.compose.chart.gant.GanttChartData
import com.gitee.wsl.compose.chart.gant.GanttChartRenderer
import com.gitee.wsl.compose.chart.gant.GanttTask

val ganttSampleView = object : SampleView {

    override val name: String = "gantt chart"

    override val thumbnail = @Composable {
        ThumbnailTheme {
            Chart.Gantt(
                renderer = getGanttChartRenderer(colors = Color.randomList(5)),
                modifier = Modifier.size(200.dp),
            )
        }
    }

    override val content: @Composable () -> Unit = @Composable {
        Chart.Gantt(
            renderer = getGanttChartRenderer(colors = Color.randomList(10)),
            modifier = Modifier.size(400.dp),
        )
    }
}


private fun getGanttChartRenderer(colors: List<Color>) =
    GanttChartRenderer(
        GanttChartData(
            taskColors = colors,
            tasks =
                listOf(
                    GanttTask("Planning", 0f, 2f),
                    GanttTask("Design", 2f, 2f),
                    GanttTask("Development", 4f, 3f),
                    GanttTask("Testing", 7f, 2f),
                    GanttTask("Deployment", 9f, 1f),
                ),
        ),
    )


